package com.yourname.action;

import com.yourname.custom.CustomCourseList;
import com.yourname.custom.CustomCourseStudentList;
import com.yourname.custom.CustomScoreStudentList;
import com.yourname.entity.*;
import com.yourname.store.DataStore;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class StudentAction {
    private static Scanner scanner=new Scanner(System.in);
    public static boolean editStudent(){
        System.out.println("请输入要修改学生的学号、新姓名、新的年龄，中间用-分割");
        String next = scanner.next();
        String[] splited = next.split("-");
        Student student = DataStore.getStudent(splited[0]);
        if (student!=null){
            student.setName(splited[1]);
            student.setAge(Integer.parseInt(splited[2]));
            System.out.println("是否修改学生密码？(true表示修改，false表示不修改)");
            boolean b = scanner.nextBoolean();
            if (b){
                System.out.println("输入新密码：");
                String newPassword = scanner.next();
                student.setPassword(newPassword);
            }
            DataStore.updateStudent(student);
            DataStore.saveData();
        }else{
            System.out.println("学生修改失败，学生"+splited[0]+"不存在");
        }
        return true;
    }
}
